package cz.acies.organizer.data.model;

import java.util.ArrayList;
import java.util.List;

import cz.acies.data.persist.ModelObject;

public class MModel extends ModelObject 
{
	private static final long serialVersionUID = -4414567696719041530L;
	
	protected String modulId;
	protected String modulPrefix;
	protected String rootId;
	
	protected List<MModelFolder> folders;
	
	protected MModelFolder root;
	protected MModelFolder selected;
	
	public MModel() {
		super();
		initialize();
		folders = new ArrayList<MModelFolder>();
		folders.add(createRootFolder());
	}
	
	protected void initialize() {
		modulId = "LX.M.00000000";
		rootId = "LX.F.00000000000ROOT";		
	}

	protected MModelFolder createRootFolder() {
		if (root == null) {
			root = new MModelFolder(rootId, "");
		}
		return root;
	}
	
	public MModelFolder createModel() {
		/*
		TModelFolder p1 = new TModelFolder("OF00000103", "118");
		TModelFolder to1 = new TModelFolder("OF00000100", "118");
		
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("INV_NUM", "OBJ1180000111");
		data.put("CUSTOMER", "Moje firma");
		data.put("DATE_WRITE", Timestamp.valueOf("2011-12-19 07:15:02"));
		data.put("SUM_VAT_RAZE", Double.valueOf("122.30"));
		TModelRecord record = new TModelRecord("OR00000001", data);
		to1.addRecord(record);
		
		data = new HashMap<String, Object>();
		data.put("INV_NUM", "OBJ1180000211");
		data.put("CUSTOMER", "St�tn� firma");
		data.put("DATE_WRITE", Timestamp.valueOf("2011-12-11 10:31:10"));
		data.put("SUM_VAT_RAZE", Double.valueOf("1024.00"));
		record = new TModelRecord("OR00000001", data);
		to1.addRecord(record);

		data = new HashMap<String, Object>();
		data.put("INV_NUM", "ZZ_DRAFT");
		data.put("CUSTOMER", "Jeho firma");
		data.put("DATE_WRITE", Timestamp.valueOf("2011-12-21 08:32:02"));
		data.put("SUM_VAT_RAZE", Double.valueOf("25.90"));
		record = new TModelRecord("OR00000001", data);
		to1.addRecord(record);

		setSelected(to1);
		
		TModelFolder to2 = new TModelFolder("OF00000101", "118 - off");
		
		p1.addChild(to1);
		p1.addChild(to2);
		
		TModelFolder p2 = new TModelFolder("OF00000201", "230");
		TModelFolder to4 = new TModelFolder("OF00000200", "230");
		p2.addChild(to4);

		root.addChild(p1);
		root.addChild(p2);
		*/
		return root;
	}
	
	public MModelFolder getRoot() {
		return root;
	}

	public void setRoot(MModelFolder root) {
		this.root = root;
	}

	public MModelFolder getSelected() {
		return selected;
	}
	
	public void setSelected(MModelFolder selected) {
		this.selected = selected;
	}

	// -----  -----------------------------------------------------------------
	
	public String getModulId() {
		return modulId;
	}

	public void setModulId(String modulId) {
		this.modulId = modulId;
	}
}
